package br.com.eduquiz.session;

import br.com.eduquiz.entity.*;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityHome;

@Name("auditoriaHome")
public class AuditoriaHome extends EntityHome<Auditoria> {
	
	private static final long serialVersionUID = 4389702923946349561L;
	
	@In(create = true)
	private PessoaHome pessoaHome;

	public void setAuditoriaId(Long id) {
		setId(id);
	}

	public Long getAuditoriaId() {
		return (Long) getId();
	}

	@Override
	protected Auditoria createInstance() {
		Auditoria auditoria = new Auditoria();
		return auditoria;
	}

	public void load() {
		if (isIdDefined()) {
			wire();
		}
	}

	public void wire() {
		getInstance();
		Pessoa pessoa = pessoaHome.getDefinedInstance();
		if (pessoa != null) {
			getInstance().setPessoa(pessoa);
		}
	}

	public boolean isWired() {
		return true;
	}

	public Auditoria getDefinedInstance() {
		return isIdDefined() ? getInstance() : null;
	}

}
